package com.mbyte.easy.admin.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mbyte.easy.admin.entity.*;
import com.mbyte.easy.admin.mapper.AllotMapper;
import com.mbyte.easy.admin.mapper.PptMapper;
import com.mbyte.easy.admin.mapper.VideoMapper;
import com.mbyte.easy.admin.service.*;
import com.mbyte.easy.common.constant.DraftLogConstant;
import com.mbyte.easy.common.constant.StatusPPTAudio;
import com.mbyte.easy.common.constant.StatusRecordVideo;
import com.mbyte.easy.common.constant.StatusWriter;
import com.mbyte.easy.common.controller.BaseController;
import com.mbyte.easy.common.web.AjaxResult;
import com.mbyte.easy.security.entity.SysRole;
import com.mbyte.easy.security.entity.SysUser;
import com.mbyte.easy.security.mapper.SysUserRolesMapper;
import com.mbyte.easy.security.service.IRoleService;
import com.mbyte.easy.security.service.IUserService;
import com.mbyte.easy.util.DateUtil;
import com.mbyte.easy.util.OssUtil;
import com.mbyte.easy.util.PageInfo;
import com.mbyte.easy.util.Utility;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static com.mbyte.easy.common.constant.StatusPPTAudio.STATUS_PPT_AUVELEADER_FAILED;

/**
* <p>
* 前端控制器
* </p>
* @author lp
* @since 2019-03-11
*/
@Slf4j
@Controller
@RequestMapping("/admin/ppt")
public class PptController extends BaseController {

    private String prefix = "admin/ppt/";


    @Autowired
    private IPptService pptService;
    @Autowired
    private IGroupService groupService;
    @Autowired
    private IAllotService allotService;
    @Autowired
    private IDraftService draftService;
    @Autowired
    private IUserService userService;
    @Autowired
    private ICheckService checkService;
    @Autowired
    IRelationService relationService;
    @Autowired
    IRoleService roleService;
    @Autowired
    SysUserRolesMapper sysUserRolesMapper;
    @Autowired
    IVideoService videoService;
    @Autowired
    VideoMapper videoMapper;
    @Autowired
    AllotMapper allotMapper;
    @Autowired
    PptMapper pptMapper;
    @Autowired
    IAudioService audioService;
    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;


    /**
     * 查询列表
     *
     * @param model
     * @param pageNo
     * @param pageSize
     * @param ppt
     * @return
     */
    @RequestMapping
    public String index(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
                        @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize,
                        String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
//        queryWrapper.eq("status_code", StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOAD)
//                .or().eq("status_code",StatusPPTAudio.STATUS_PPT_SECTIONLEADER_SUCCESS)
//                .or().eq("status_code",StatusPPTAudio.STATUS_PPT_VIDEOREADER_SUCCESS);
        queryWrapper.in("status_code", StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOAD, StatusPPTAudio.STATUS_PPT_SECTIONLEADER_SUCCESS, StatusPPTAudio.STATUS_PPT_VIDEOREADER_SUCCESS);
        if (!ObjectUtils.isEmpty(ppt.getDraftId())) {
            queryWrapper = queryWrapper.like("draft_id", ppt.getDraftId());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptUrl())) {
            queryWrapper = queryWrapper.like("ppt_url", ppt.getPptUrl());
        }
        if (!ObjectUtils.isEmpty(ppt.getSubmitTime())) {
            queryWrapper = queryWrapper.like("submit_time", ppt.getSubmitTime());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptMaker())) {
            queryWrapper = queryWrapper.like("ppt_maker", ppt.getPptMaker());
        }
        if (!ObjectUtils.isEmpty(ppt.getStatusCode())) {
            queryWrapper = queryWrapper.like("status_code", ppt.getStatusCode());
        }
        if (!ObjectUtils.isEmpty(ppt.getIsDelete())) {
            queryWrapper = queryWrapper.like("is_delete", ppt.getIsDelete());
        }
        IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
        model.addAttribute("submitTimeSpace", submitTimeSpace);
        model.addAttribute("searchInfo", ppt);
        model.addAttribute("pageInfo", new PageInfo(pageInfo));
        return prefix + "list";
    }

    /**
     * @author 孙祺至
     * @date 2019/12/12 23:19
     * PPT录屏制作人
     * 审核中
     */
    @RequestMapping("PPT_reviewing")
    public String PPT_reviewing(Model model,
                                @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
                                @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize,
                                String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt,Draft draft) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();

        if (!ObjectUtils.isEmpty(draft.getDraftTitle())) {
            QueryWrapper<Draft> draftQueryWrapper=new QueryWrapper<>();
            draftQueryWrapper.lambda().like(Draft::getDraftTitle,draft.getDraftTitle());
            List<Draft> draftlist = draftService.list(draftQueryWrapper);
            if (draftlist.size()!=0){
                queryWrapper=queryWrapper.in("tp.draft_id",draftlist.stream().map(Draft::getId).collect(Collectors.toList()));
            }else {
                queryWrapper.eq("tp.group_id","0");
            }
        }

        if(!ObjectUtils.isEmpty(ppt.getGroupId())) {
            QueryWrapper<Group> groupQueryWrapper=new QueryWrapper<>();
            groupQueryWrapper.lambda().like(Group::getName,ppt.getGroupId());
            List<Group> list = groupService.list(groupQueryWrapper);
            if (list.size()!=0){
                queryWrapper = queryWrapper.in("tp.group_id",list.stream().map(Group::getGroupId).collect(Collectors.toList()));
            }
        }
        queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);
        String currentUsername = Utility.getCurrentUsername();
        queryWrapper.eq("tp.ppt_maker", currentUsername);
        queryWrapper.in("tp.status_code", StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOADTO,
                StatusPPTAudio.STATUS_PPT_BUTTJOJINT_SUCCESS);
//        log.info("=====pptmaker========>>>>{}", Utility.getCurrentUsername());
//        IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
        //稿件标题+文件名
//        Map<Long,String> map=new HashMap<>();
//        Map<Long,String> filemap=new HashMap<>();
//        List<Ppt> list = pptService.list(queryWrapper);
//        for (int i = 0; i < list.size(); i++) {
//            map.put(list.get(i).getId(),draftService.getTitleById(list.get(i).getDraftId()));
//            filemap.put(list.get(i).getId(),draftService.getFileNameById(list.get(i).getDraftId()));
//        }
//        model.addAttribute("map",map);
//        model.addAttribute("filemap",filemap);

        //组名
//        List<Ppt> list1 = pptService.list(queryWrapper);
//        Map<String,String> groupMap=new HashMap<>();
//        for (int i = 0; i < list1.size(); i++) {
//            String name = groupService.getNameByGroupId(list1.get(i).getGroupId());
//            groupMap.put(list1.get(i).getGroupId(),name);
//        }
//        log.info("============list1========="+list1);
//        log.info("============mao========="+groupMap);
//        model.addAttribute("groupMap", groupMap);

        IPage<Ppt> pageInfo = pptService.listPage(page, queryWrapper);
        model.addAttribute("submitTimeSpace", submitTimeSpace);
        model.addAttribute("searchInfo", ppt);
        model.addAttribute("searchInfoDraft", draft);
        model.addAttribute("pageInfo", new PageInfo(pageInfo));
        return prefix + "reviewing";
    }

    /**
     * @author 孙祺至
     * @date 2019/12/12 23:19
     * PPT录屏制作人
     * 审核通过
     */
    @RequestMapping("PPT_success_reviewed")
    public String PPT_success_reviewed(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt,Draft draft) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
        if (!ObjectUtils.isEmpty(draft.getDraftTitle())) {
            QueryWrapper<Draft> draftQueryWrapper=new QueryWrapper<>();
            draftQueryWrapper.lambda().like(Draft::getDraftTitle,draft.getDraftTitle());
            List<Draft> draftlist = draftService.list(draftQueryWrapper);
            if (draftlist.size()!=0){
                queryWrapper=queryWrapper.in("tp.draft_id",draftlist.stream().map(Draft::getId).collect(Collectors.toList()));
            }else {
                queryWrapper.eq("tp.group_id","0");
            }
        }

        if(!ObjectUtils.isEmpty(ppt.getGroupId())) {
            QueryWrapper<Group> groupQueryWrapper=new QueryWrapper<>();
            groupQueryWrapper.lambda().like(Group::getName,ppt.getGroupId());
            List<Group> list = groupService.list(groupQueryWrapper);
            if (list.size()!=0){
                queryWrapper = queryWrapper.in("tp.group_id",list.stream().map(Group::getGroupId).collect(Collectors.toList()));
            }
        }
        queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);
        queryWrapper.eq("ppt_maker", Utility.getCurrentUsername());
        queryWrapper.in("tp.status_code", StatusPPTAudio.STATUS_PPT_FUNCTIONARY_SUCCESS);

        //稿件标题+文件名
//        Map<Long,String> map=new HashMap<>();
//        Map<Long,String> filemap=new HashMap<>();
//        List<Ppt> list = pptService.list(queryWrapper);
//        for (int i = 0; i < list.size(); i++) {
//            map.put(list.get(i).getId(),draftService.getTitleById(list.get(i).getDraftId()));
//            filemap.put(list.get(i).getId(),draftService.getFileNameById(list.get(i).getDraftId()));
//        }
//        model.addAttribute("map",map);
//        model.addAttribute("filemap",filemap);


        //组名
//        List<Ppt> list1 = pptService.list(queryWrapper);
//        Map<String,String> groupMap=new HashMap<>();
//        for (int i = 0; i < list1.size(); i++) {
//            String name = groupService.getNameByGroupId(list1.get(i).getGroupId());
//            groupMap.put(list1.get(i).getGroupId(),name);
//        }
//        log.info("============list1========="+list1);
//        log.info("============mao========="+groupMap);
//        model.addAttribute("groupMap", groupMap);
        IPage<Ppt> pageInfo = pptService.listPage(page, queryWrapper);
//        IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
        model.addAttribute("submitTimeSpace", submitTimeSpace);
        model.addAttribute("searchInfo", ppt);
        model.addAttribute("searchInfoDraft", draft);
        model.addAttribute("pageInfo", new PageInfo(pageInfo));
        return prefix + "success";
    }

    /**
     * @author 孙祺至
     * @date 2019/12/12 23:19
     * PPT录屏制作人
     * 审核被驳回
     */
    @RequestMapping("PPT_failed_reviewed")
    public String PPT_failed_reviewed(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt,Draft draft
    ) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();

        if (!ObjectUtils.isEmpty(draft.getDraftTitle())) {
            QueryWrapper<Draft> draftQueryWrapper=new QueryWrapper<>();
            draftQueryWrapper.lambda().like(Draft::getDraftTitle,draft.getDraftTitle());
            List<Draft> draftlist = draftService.list(draftQueryWrapper);
            if (draftlist.size()!=0){
                queryWrapper=queryWrapper.in("tp.draft_id",draftlist.stream().map(Draft::getId).collect(Collectors.toList()));
            }else {
                queryWrapper.eq("tp.group_id","0");
            }
        }

        if(!ObjectUtils.isEmpty(ppt.getGroupId())) {
            QueryWrapper<Group> groupQueryWrapper=new QueryWrapper<>();
            groupQueryWrapper.lambda().like(Group::getName,ppt.getGroupId());
            List<Group> list = groupService.list(groupQueryWrapper);
            if (list.size()!=0){
                queryWrapper = queryWrapper.in("tp.group_id",list.stream().map(Group::getGroupId).collect(Collectors.toList()));
            }
        }
        queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);
        queryWrapper.lambda().eq(Ppt::getPptMaker,Utility.getCurrentUsername());
        log.info("========"+Utility.getCurrentUsername());
        queryWrapper.in("tp.status_code",StatusPPTAudio.STATUS_PPT_BUTTJOJINT_FAILED);
        Map<Integer, String> draftTypes = new HashMap<>();
        draftTypes.put(2033, "对接人拒绝");
        draftTypes.put(2034, "负责人拒绝");
        draftTypes.put(2016, "音视频校对组长拒绝");


        IPage<Ppt> pageInfo = pptService.listPage(page, queryWrapper);

        model.addAttribute("draftTypes", draftTypes);
        model.addAttribute("submitTimeSpace", submitTimeSpace);
        model.addAttribute("searchInfo", ppt);
        model.addAttribute("searchInfoDraft", draft);
        model.addAttribute("pageInfo", new PageInfo(pageInfo));
        return prefix + "failed";
    }

    /**
     * @author 孙祺至
     * @date 2019/12/12 23:19
     * 板块负责人
     * 未审核
     */
    @RequestMapping("PPT_SectionLeader_Unviewed")
    public String PPT_SectionLeader_Unviewed(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
        if (!ObjectUtils.isEmpty(ppt.getDraftId())) {
            queryWrapper = queryWrapper.like("draft_id", ppt.getDraftId());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptUrl())) {
            queryWrapper = queryWrapper.like("ppt_url", ppt.getPptUrl());
        }
        if (!ObjectUtils.isEmpty(ppt.getSubmitTime())) {
            queryWrapper = queryWrapper.like("submit_time", ppt.getSubmitTime());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptMaker())) {
            queryWrapper = queryWrapper.like("ppt_maker", ppt.getPptMaker());
        }
        if (!ObjectUtils.isEmpty(ppt.getStatusCode())) {
            queryWrapper = queryWrapper.like("status_code", ppt.getStatusCode());
        }
        if (!ObjectUtils.isEmpty(ppt.getIsDelete())) {
            queryWrapper = queryWrapper.like("is_delete", ppt.getIsDelete());
        }
        queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);

        QueryWrapper<Relation> relationQueryWrapper = new QueryWrapper<>();
        Long aLong = pptService.selectIdByUsername(Utility.getCurrentUsername());
        relationQueryWrapper.lambda().eq(Relation::getParentId, aLong);
        List<Relation> list = relationService.list(relationQueryWrapper);
        QueryWrapper<Draft> draftQueryWrapper = new QueryWrapper<>();
        if (list.size() != 0) {
            log.info("================所有版块负责人的下属=========" + list);
            draftQueryWrapper.lambda().in(Draft::getUserId, list.stream().map(Relation::getUserId).collect(Collectors.toList()));
            List<Draft> list1 = draftService.list(draftQueryWrapper);
            if (list1.size() != 0) {
                log.info("================所有板块负责人下属提交的稿件==========" + list1);
                queryWrapper.lambda().in(Ppt::getDraftId, list1.stream().map(Draft::getId).collect(Collectors.toList()));
                log.info("===============与ppt表的draftid相同的ppt=======" + pptService.list(queryWrapper));
                queryWrapper.lambda().eq(Ppt::getStatusCode, StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOAD);
                IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
                model.addAttribute("submitTimeSpace", submitTimeSpace);
                model.addAttribute("searchInfo", ppt);
                model.addAttribute("pageInfo", new PageInfo(pageInfo));
                return prefix + "SectionLeaderUnviewed";
            }else {
                queryWrapper.lambda().eq(Ppt::getStatusCode, StatusWriter.ERROR);
                IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
                model.addAttribute("submitTimeSpace", submitTimeSpace);
                model.addAttribute("searchInfo", ppt);
                model.addAttribute("pageInfo", new PageInfo(pageInfo));
                return prefix + "SectionLeaderUnviewed";
            }
        } else {
            queryWrapper.lambda().eq(Ppt::getStatusCode, StatusWriter.ERROR);
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "SectionLeaderUnviewed";
        }
    }



    /**
     * @author 孙祺至
     * @date 2019/12/12 23:19
     * 板块负责人
     * 审核通过
     */
    @RequestMapping("PPT_SectionLeader_Success_Reviewed")
    public String PPT_SectionLeader_Success_Reviewed(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
        if (!ObjectUtils.isEmpty(ppt.getDraftId())) {
            queryWrapper = queryWrapper.like("draft_id", ppt.getDraftId());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptUrl())) {
            queryWrapper = queryWrapper.like("ppt_url", ppt.getPptUrl());
        }
        if (!ObjectUtils.isEmpty(ppt.getSubmitTime())) {
            queryWrapper = queryWrapper.like("submit_time", ppt.getSubmitTime());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptMaker())) {
            queryWrapper = queryWrapper.like("ppt_maker", ppt.getPptMaker());
        }
        if (!ObjectUtils.isEmpty(ppt.getStatusCode())) {
            queryWrapper = queryWrapper.like("status_code", ppt.getStatusCode());
        }
        if (!ObjectUtils.isEmpty(ppt.getIsDelete())) {
            queryWrapper = queryWrapper.like("is_delete", ppt.getIsDelete());
        }
        queryWrapper.lambda().orderByDesc(Ppt::getCreateTime);
        SysUser sysUser = pptService.getUserByUserName(Utility.getCurrentUsername());
        List<Check> groupByUserId = pptService.getChecksByIdUnPass(sysUser.getId());
        if (groupByUserId.size()!=0){
            log.info("groupByUserId==============>>>>{}",groupByUserId);
            queryWrapper.in("id", groupByUserId.stream().map(Check::getDraftId).collect(Collectors.toList()));
            queryWrapper.lambda().ge(Ppt::getStatusCode, StatusPPTAudio.STATUS_PPT_SECTIONLEADER_SUCCESS);
            queryWrapper.lambda().ne(Ppt::getStatusCode, STATUS_PPT_AUVELEADER_FAILED)
                    .ne(Ppt::getStatusCode,StatusPPTAudio.STATUS_PPT_VIDEOREADER_FAILED)
                    .ne(Ppt::getStatusCode,StatusPPTAudio.STATUS_AUDIO_AUVELEADER_FAILED)
                    .ne(Ppt::getStatusCode,StatusPPTAudio.STATUS_AUDIO_AUDIOREADER_FAILED)
                    .ne(Ppt::getStatusCode,StatusPPTAudio.STATUS_PPT_SECTIONLEADER_FAILED);
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "SectionLeaderSuccessReviewed";
        }else {
            queryWrapper.lambda().eq(Ppt::getStatusCode, StatusWriter.ERROR);
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "SectionLeaderSuccessReviewed";
        }

    }

    /**
     * @author 孙祺至
     * @date 2019/12/12 23:19
     * 板块负责人
     * 审核驳回
     */
    @RequestMapping("PPT_SectionLeader_Failed_Reviewed")
    public String PPT_SectionLeader_Failed_Reviewed(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
        if (!ObjectUtils.isEmpty(ppt.getDraftId())) {
            queryWrapper = queryWrapper.like("draft_id", ppt.getDraftId());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptUrl())) {
            queryWrapper = queryWrapper.like("ppt_url", ppt.getPptUrl());
        }
        if (!ObjectUtils.isEmpty(ppt.getSubmitTime())) {
            queryWrapper = queryWrapper.like("submit_time", ppt.getSubmitTime());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptMaker())) {
            queryWrapper = queryWrapper.like("ppt_maker", ppt.getPptMaker());
        }
        if (!ObjectUtils.isEmpty(ppt.getStatusCode())) {
            queryWrapper = queryWrapper.like("status_code", ppt.getStatusCode());
        }
        if (!ObjectUtils.isEmpty(ppt.getIsDelete())) {
            queryWrapper = queryWrapper.like("is_delete", ppt.getIsDelete());
        }
        queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);
        SysUser sysUser = pptService.getUserByUserName(Utility.getCurrentUsername());
        List<Check> groupByUserId = pptService.getChecksByIdPass(sysUser.getId());
        if(groupByUserId.size()!=0){
            queryWrapper.in("id", groupByUserId.stream().map(Check::getDraftId).collect(Collectors.toList()));
             queryWrapper.lambda().eq(Ppt::getStatusCode, StatusPPTAudio.STATUS_PPT_SECTIONLEADER_FAILED);
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "SectionLeaderFailedReviewed";
        }else{
            queryWrapper.lambda().eq(Ppt::getStatusCode, StatusWriter.ERROR);
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "SectionLeaderFailedReviewed";
        }
    }
    /**
     *@author 孙祺至
     *@date 2019/12/27 10:29
     * 板块负责人
     * 被驳回
     */
    @RequestMapping("SLeaderBeFailed")
    public String SLeaderBeFailed(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
        if (!ObjectUtils.isEmpty(ppt.getDraftId())) {
            queryWrapper = queryWrapper.like("draft_id", ppt.getDraftId());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptUrl())) {
            queryWrapper = queryWrapper.like("ppt_url", ppt.getPptUrl());
        }
        if (!ObjectUtils.isEmpty(ppt.getSubmitTime())) {
            queryWrapper = queryWrapper.like("submit_time", ppt.getSubmitTime());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptMaker())) {
            queryWrapper = queryWrapper.like("ppt_maker", ppt.getPptMaker());
        }
        if (!ObjectUtils.isEmpty(ppt.getStatusCode())) {
            queryWrapper = queryWrapper.like("status_code", ppt.getStatusCode());
        }
        if (!ObjectUtils.isEmpty(ppt.getIsDelete())) {
            queryWrapper = queryWrapper.like("is_delete", ppt.getIsDelete());
        }
        queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);
        SysUser sysUser = pptService.getUserByUserName(Utility.getCurrentUsername());
        List<Check> groupByUserId = pptService.getChecksByIdUnPass(sysUser.getId());
        if(groupByUserId.size()!=0){
            queryWrapper.in("id", groupByUserId.stream().map(Check::getDraftId).collect(Collectors.toList()));
            log.info("===groupByUserId==={}",groupByUserId);
            queryWrapper.lambda().in(Ppt::getStatusCode, StatusPPTAudio.STATUS_PPT_VIDEOREADER_FAILED,
                    STATUS_PPT_AUVELEADER_FAILED);//2015.2016
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "SectionLeaderBeFailed";
        }else{
            queryWrapper.lambda().eq(Ppt::getStatusCode, StatusWriter.ERROR);
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "SectionLeaderBeFailed";
        }
    }

    /**
     * @author 孙祺至
     * @date 2019年12月16日11:27:06
     * 视频校对人
     * 未校对PPT
     */
    @RequestMapping("vReaderUnReview")
    public String vReaderUnReview(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
        if (!ObjectUtils.isEmpty(ppt.getDraftId())) {
            queryWrapper = queryWrapper.like("draft_id", ppt.getDraftId());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptUrl())) {
            queryWrapper = queryWrapper.like("ppt_url", ppt.getPptUrl());
        }
        if (!ObjectUtils.isEmpty(ppt.getSubmitTime())) {
            queryWrapper = queryWrapper.like("submit_time", ppt.getSubmitTime());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptMaker())) {
            queryWrapper = queryWrapper.like("ppt_maker", ppt.getPptMaker());
        }
        if (!ObjectUtils.isEmpty(ppt.getStatusCode())) {
            queryWrapper = queryWrapper.like("status_code", ppt.getStatusCode());
        }
        if (!ObjectUtils.isEmpty(ppt.getIsDelete())) {
            queryWrapper = queryWrapper.like("is_delete", ppt.getIsDelete());
        }
        if(!ObjectUtils.isEmpty(ppt.getGroupId())) {
            QueryWrapper<Group> groupQueryWrapper=new QueryWrapper<>();
            groupQueryWrapper.lambda().like(Group::getName,ppt.getGroupId());
            List<Group> list = groupService.list(groupQueryWrapper);
            if (list.size()!=0){
                queryWrapper = queryWrapper.in("tp.group_id",list.stream().map(Group::getGroupId).collect(Collectors.toList()));
            }else {
                queryWrapper.eq("tp.group_id","0");
            }
        }
        queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);
        Long sysUser = draftService.getIdByUserName(Utility.getCurrentUsername());
        //获取登录人分配的所有稿件id
        List<Long> groupByUserId = pptService.getAllotDraftIdByUserId(sysUser);
        if (groupByUserId.size()!=0){

            //稿件标题+文件名
//            Map<Long,String> map=new HashMap<>();
//            Map<Long,String> filemap=new HashMap<>();
//            List<Ppt> list = pptService.list(queryWrapper);
//            for (int i = 0; i < list.size(); i++) {
//                map.put(list.get(i).getId(),draftService.getTitleById(list.get(i).getDraftId()));
//                filemap.put(list.get(i).getId(),draftService.getFileNameById(list.get(i).getDraftId()));
//            }
//            model.addAttribute("map",map);
//            model.addAttribute("filemap",filemap);

            //组名
//            List<Ppt> list1 = pptService.list(queryWrapper);
//            Map<String,String> groupMap=new HashMap<>();
//            for (int i = 0; i < list1.size(); i++) {
//                String name = groupService.getNameByGroupId(list1.get(i).getGroupId());
//                groupMap.put(list1.get(i).getGroupId(),name);
//            }
//            log.info("============list1========="+list1);
//            log.info("============mao========="+groupMap);
//            model.addAttribute("groupMap", groupMap);


            //判断分配的稿件id与PPT的稿件相同
            queryWrapper.in("tp.draft_id", groupByUserId);
            //判断PPTstatuscode是板块负责人通过的
            queryWrapper.eq("tp.status_code", StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOADTO);
            IPage<Ppt> pageInfo = pptService.listPage(page, queryWrapper);
//            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "VReaderUnreview";
        }else {
            queryWrapper.lambda().eq(Ppt::getStatusCode, StatusWriter.ERROR);
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "VReaderUnreview";
        }

    }

    /**
     * @author 孙祺至
     * @date 2019年12月16日11:26:34
     * 视频校对人
     * 校对通过PPT
     */
    @RequestMapping("vReaderSuccess")
    public String vReaderSuccess(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
        if (!ObjectUtils.isEmpty(ppt.getDraftId())) {
            queryWrapper = queryWrapper.like("draft_id", ppt.getDraftId());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptUrl())) {
            queryWrapper = queryWrapper.like("ppt_url", ppt.getPptUrl());
        }
        if (!ObjectUtils.isEmpty(ppt.getSubmitTime())) {
            queryWrapper = queryWrapper.like("submit_time", ppt.getSubmitTime());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptMaker())) {
            queryWrapper = queryWrapper.like("ppt_maker", ppt.getPptMaker());
        }
        if (!ObjectUtils.isEmpty(ppt.getStatusCode())) {
            queryWrapper = queryWrapper.like("status_code", ppt.getStatusCode());
        }
        if (!ObjectUtils.isEmpty(ppt.getIsDelete())) {
            queryWrapper = queryWrapper.like("is_delete", ppt.getIsDelete());
        }
        if(!ObjectUtils.isEmpty(ppt.getGroupId())) {
            QueryWrapper<Group> groupQueryWrapper=new QueryWrapper<>();
            groupQueryWrapper.lambda().like(Group::getName,ppt.getGroupId());
            List<Group> list = groupService.list(groupQueryWrapper);
            if (list.size()!=0){
                queryWrapper = queryWrapper.in("tp.group_id",list.stream().map(Group::getGroupId).collect(Collectors.toList()));
            }else {
                queryWrapper.eq("tp.group_id","0");
            }
        }
        queryWrapper.lambda().orderByDesc(Ppt::getCreateTime);
        SysUser sysUser = pptService.getUserByUserName(Utility.getCurrentUsername());
        //获取登录人分配的所有稿件id
        List<Long> groupByUserId = pptService.getAllotDraftIdByUserId(sysUser.getId());
        if (groupByUserId.size()!=0){
            //判断分配的稿件id与PPT的稿件相同
            queryWrapper.in("tp.draft_id", groupByUserId);
            queryWrapper.in("tp.status_code", StatusPPTAudio.STATUS_PPT_BUTTJOJINT_SUCCESS,//1033
                    StatusPPTAudio.STATUS_PPT_FUNCTIONARY_SUCCESS,//1034
                    StatusPPTAudio.STATUS_PPT_FUNCTIONARY_FAILED,//2034
                    StatusPPTAudio.STATUS_PPT_BUTTJOJINT_DISTRIBUTION,//1031
                    StatusPPTAudio.STATUS_PPT_FUNCTIONARY_DISTRIBUTION,//1030
                    StatusPPTAudio.STATUFUNCTIONARY_FAILED,//2029
                    StatusPPTAudio.STATUFUNCTIONARY_SUCCESS_L,//1029
                    StatusPPTAudio.STATUFUNCTIONARY_FAILED_F,//2028
                    StatusPPTAudio.STATUFUNCTIONARY_SUCCESS,//1028
                    StatusPPTAudio.STATUFUNCTIONARY_SUCCESS_O,//1027
                    StatusPPTAudio.STATUS_FUNCTIONARY_SUCCESS_L,//1039
                    StatusPPTAudio.STATUS_FUNCTIONARY_FAILED,//2038
                    StatusPPTAudio.STATUS_FUNCTIONARY_SUCCESS,//1038
                    StatusPPTAudio.STATUS_T_FUNCTIONARY_FAILED//1037
                    );
            //稿件标题+文件名
//            Map<Long,String> map=new HashMap<>();
//            Map<Long,String> filemap=new HashMap<>();
//            List<Ppt> list = pptService.list(queryWrapper);
//            for (int i = 0; i < list.size(); i++) {
//                map.put(list.get(i).getId(),draftService.getTitleById(list.get(i).getDraftId()));
//                filemap.put(list.get(i).getId(),draftService.getFileNameById(list.get(i).getDraftId()));
//            }
//            model.addAttribute("map",map);
//            model.addAttribute("filemap",filemap);


            //组名
//            List<Ppt> list1 = pptService.list(queryWrapper);
//            Map<String,String> groupMap=new HashMap<>();
//            for (int i = 0; i < list1.size(); i++) {
//                String name = groupService.getNameByGroupId(list1.get(i).getGroupId());
//                groupMap.put(list1.get(i).getGroupId(),name);
//            }
//            log.info("============list1========="+list1);
//            log.info("============mao========="+groupMap);
//            model.addAttribute("groupMap", groupMap);
            IPage<Ppt> pageInfo = pptService.listPage(page, queryWrapper);
//            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "VReaderSuccessReviewed";
        }else{
            queryWrapper.lambda().eq(Ppt::getStatusCode, StatusWriter.ERROR);
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "VReaderSuccessReviewed";
        }
    }

    /**
     * @author 孙祺至
     * @date 2019年12月16日11:26:34
     * 视频校对人
     * 校对拒绝PPT
     */
    @RequestMapping("vReaderFailed")
    public String vReaderFailed(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
        if (!ObjectUtils.isEmpty(ppt.getDraftId())) {
            queryWrapper = queryWrapper.like("draft_id", ppt.getDraftId());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptUrl())) {
            queryWrapper = queryWrapper.like("ppt_url", ppt.getPptUrl());
        }
        if (!ObjectUtils.isEmpty(ppt.getSubmitTime())) {
            queryWrapper = queryWrapper.like("submit_time", ppt.getSubmitTime());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptMaker())) {
            queryWrapper = queryWrapper.like("ppt_maker", ppt.getPptMaker());
        }
        if (!ObjectUtils.isEmpty(ppt.getStatusCode())) {
            queryWrapper = queryWrapper.like("status_code", ppt.getStatusCode());
        }
        if (!ObjectUtils.isEmpty(ppt.getIsDelete())) {
            queryWrapper = queryWrapper.like("is_delete", ppt.getIsDelete());
        }
        if(!ObjectUtils.isEmpty(ppt.getGroupId())) {
            QueryWrapper<Group> groupQueryWrapper=new QueryWrapper<>();
            groupQueryWrapper.lambda().like(Group::getName,ppt.getGroupId());
            List<Group> list = groupService.list(groupQueryWrapper);
            if (list.size()!=0){
                queryWrapper = queryWrapper.in("tp.group_id",list.stream().map(Group::getGroupId).collect(Collectors.toList()));
            }else {
                queryWrapper.eq("tp.group_id","0");
            }
        }
        queryWrapper.lambda().orderByDesc(Ppt::getCreateTime);
        SysUser sysUser = pptService.getUserByUserName(Utility.getCurrentUsername());
        //获取登录人分配的所有稿件id
        List<Long> groupByUserId = pptService.getAllotDraftIdByUserId(sysUser.getId());
        if (groupByUserId.size()!=0){
            //判断分配的稿件id与PPT的稿件相同
            queryWrapper.in("tp.draft_id", groupByUserId);
            //判断PPTstatuscode是板块负责人通过的
            queryWrapper.eq("tp.status_code", StatusPPTAudio.STATUS_PPT_BUTTJOJINT_FAILED);
//            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);

//            //稿件标题+文件名
//            Map<Long,String> map=new HashMap<>();
//            Map<Long,String> filemap=new HashMap<>();
//            List<Ppt> list = pptService.list(queryWrapper);
//            for (int i = 0; i < list.size(); i++) {
//                map.put(list.get(i).getId(),draftService.getTitleById(list.get(i).getDraftId()));
//                filemap.put(list.get(i).getId(),draftService.getFileNameById(list.get(i).getDraftId()));
//            }
//            model.addAttribute("map",map);
//            model.addAttribute("filemap",filemap);

            //组名
//            List<Ppt> list1 = pptService.list(queryWrapper);
//            Map<String,String> groupMap=new HashMap<>();
//            for (int i = 0; i < list1.size(); i++) {
//                String name = groupService.getNameByGroupId(list1.get(i).getGroupId());
//                groupMap.put(list1.get(i).getGroupId(),name);
//            }
//            log.info("============list1========="+list1);
//            log.info("============mao========="+groupMap);
//            model.addAttribute("groupMap", groupMap);

            IPage<Ppt> pageInfo = pptService.listPage(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "VReaderFailedReviewed";
        }else{
            queryWrapper.lambda().eq(Ppt::getStatusCode, StatusWriter.ERROR);
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "VReaderFailedReviewed";
        }
    }
    /**
     *@author 孙祺至
     *@date 2019/12/27 11:11
     * 视频校对人
     * 被驳回
     */
    @RequestMapping("AReaderBeFailed")
    public String AReaderBeFailed(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
        if (!ObjectUtils.isEmpty(ppt.getDraftId())) {
            queryWrapper = queryWrapper.like("draft_id", ppt.getDraftId());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptUrl())) {
            queryWrapper = queryWrapper.like("ppt_url", ppt.getPptUrl());
        }
        if (!ObjectUtils.isEmpty(ppt.getSubmitTime())) {
            queryWrapper = queryWrapper.like("submit_time", ppt.getSubmitTime());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptMaker())) {
            queryWrapper = queryWrapper.like("ppt_maker", ppt.getPptMaker());
        }
        if (!ObjectUtils.isEmpty(ppt.getStatusCode())) {
            queryWrapper = queryWrapper.like("status_code", ppt.getStatusCode());
        }
        if (!ObjectUtils.isEmpty(ppt.getIsDelete())) {
            queryWrapper = queryWrapper.like("is_delete", ppt.getIsDelete());
        }
        if(!ObjectUtils.isEmpty(ppt.getGroupId())) {
            QueryWrapper<Group> groupQueryWrapper=new QueryWrapper<>();
            groupQueryWrapper.lambda().like(Group::getName,ppt.getGroupId());
            List<Group> list = groupService.list(groupQueryWrapper);
            if (list.size()!=0){
                queryWrapper = queryWrapper.in("tp.group_id",list.stream().map(Group::getGroupId).collect(Collectors.toList()));
            }else {
                queryWrapper.eq("tp.group_id","0");
            }
        }
        queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);
        SysUser sysUser = pptService.getUserByUserName(Utility.getCurrentUsername());
        //获取登录人分配的所有稿件id
        List<Long> groupByUserId = pptService.getAllotDraftIdByUserId(sysUser.getId());
        if (groupByUserId.size()!=0){
            //判断分配的稿件id与PPT的稿件相同
            queryWrapper.in("tp.draft_id", groupByUserId);
            //判断PPTstatuscode是板块负责人通过的
            queryWrapper.eq("tp.status_code",StatusPPTAudio.STATUS_PPT_FUNCTIONARY_FAILED);

            IPage<Ppt> pageInfo = pptService.listPage(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "VReaderBeFailed";
        }else{
            queryWrapper.lambda().eq(Ppt::getStatusCode, StatusWriter.ERROR);
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "VReaderBeFailed";
        }
    }

    /**
     * @author 孙祺至
     * @date 2019年12月16日11:26:34
     * 音视频校对组长
     * 未校对PPT
     */
    @RequestMapping("auviLeaderUnReview")
    public String auviLeaderUnReview(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
                                     @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize,
                                     String submitTimeSpace, String createTimeSpace, String updateTimeSpace,
                                     Ppt ppt) {
        //这是list页面
        Page<Ppt> page = new Page<>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<>();


        queryWrapper.eq("tp.status_code",StatusPPTAudio.STATUS_PPT_BUTTJOJINT_SUCCESS);//下一级通过1033
        //这是组编号的回显
        QueryWrapper<Ppt> videoQueryWrapper=new QueryWrapper<>();
        videoQueryWrapper.eq("status_code",StatusPPTAudio.STATUS_PPT_BUTTJOJINT_SUCCESS);
        log.info("======videoQueryWrapper第一阶段=========>>>>{}",pptService.list(videoQueryWrapper));
        videoQueryWrapper.groupBy("group_id");
        log.info("======videoQueryWrapper第二阶段=========>>>>{}",pptService.list(videoQueryWrapper));
        queryWrapper.lambda().orderByDesc(Ppt::getCreateTime);

        //2020/2/9修改
        //QueryWrapper<Ppt> videos = new QueryWrapper<>();
       // videos.eq("group_id",ppt.getGroupId());
        QueryWrapper<Draft> draftQueryWrapper=new QueryWrapper<>();
        draftQueryWrapper.eq("group_id",ppt.getGroupId());
        List<Draft> list = draftService.list(draftQueryWrapper);

        //所有的登录人组长的下属idList
        List<Long> childrenIdByParentId = pptService.getChildrenIdByParentId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());

        //IdList与t_group表的userId所对应。
        QueryWrapper<Group> groupQueryWrapper=new QueryWrapper<>();
        if (childrenIdByParentId!=null){
            childrenIdByParentId.add(-1L);
            groupQueryWrapper=groupQueryWrapper.in("user_id",childrenIdByParentId);
        }
        //获取groupList
        List<Group> groupList = groupService.list(groupQueryWrapper);

        log.info(groupList+"yyyyyyyyyyyyyyy");
        List<String> stringList=new ArrayList<>(groupList.size());
        if (groupList != null){
            for (int i = 0; i < groupList.size(); i++) {
                stringList.add(groupList.get(i).getGroupId());
            }
            log.info("zheges"+stringList);
            //获取GroupList的group_id字段
            if(!CollectionUtils.isEmpty(stringList)) {
                videoQueryWrapper = videoQueryWrapper.in("group_id", stringList);
            }
        }
        List<Ppt> videoList=pptService.list(videoQueryWrapper);
        log.info(videoList+"hhhhhhhhhhhhhhhhhhh");
        if (videoList!=null){
            for(Ppt video1:videoList){
                for (Group group : groupList) {
                    if(video1.getGroupId().equals(group.getGroupId())){
                        video1.setGroupName(group.getName());
                    }
                }
            }
            model.addAttribute("videoList", videoList);
        }else{
            model.addAttribute("videoList", 0);
        }
        log.info("======videoQueryWrapper第三阶段=========>>>>{}",pptService.list(videoQueryWrapper));
        if(!ObjectUtils.isEmpty(ppt.getGroupId())){
            queryWrapper = queryWrapper.eq("tp.group_id",ppt.getGroupId());
        }else {
            if (!ObjectUtils.isEmpty(stringList)){
            queryWrapper.in("tp.group_id",stringList);
            }
        }
        if (videoList!=null){
            log.info("=========video.size()=======>>>>{}",videoList.size());
            model.addAttribute("videoListSize", list.size());
        }else {
            model.addAttribute("videoListSize", 0);
        }
        if (ObjectUtils.isEmpty(ppt.getGroupId())){
            QueryWrapper<Ppt> pptQueryWrapper=new QueryWrapper<>();
            pptQueryWrapper.eq("status_code",StatusWriter.ERROR);
            IPage<Ppt> pageInfo = pptService.page(page, pptQueryWrapper);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "AuViLeaderUnreview";
        }
//        IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);

        //稿件标题+文件名
//        Map<Long,String> map=new HashMap<>();
//        Map<Long,String> filemap=new HashMap<>();
//        List<Ppt> list2 = pptService.list(queryWrapper);
//        for (int i = 0; i < list2.size(); i++) {
//            map.put(list2.get(i).getId(),draftService.getById(list2.get(i).getDraftId()).getDraftTitle());
//            filemap.put(list2.get(i).getId(),draftService.getById(list2.get(i).getDraftId()).getFileName());
//        }
//        model.addAttribute("map",map);
//        model.addAttribute("filemap",filemap);
        IPage<Ppt> pageInfo = pptService.listPage(page, queryWrapper);
        model.addAttribute("searchInfo", ppt);
        model.addAttribute("pageInfo", new PageInfo(pageInfo));
        return prefix + "AuViLeaderUnreview";
    }

    /**
     * @author 孙祺至
     * @date 2019年12月16日11:26:34
     * 音视频校对组长
     * 校对通过PPT
     */
    @RequestMapping("auviLeaderSuccess")
    public String auviLeaderSuccess(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
        if (!ObjectUtils.isEmpty(ppt.getDraftId())) {
            queryWrapper = queryWrapper.like("draft_id", ppt.getDraftId());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptUrl())) {
            queryWrapper = queryWrapper.like("ppt_url", ppt.getPptUrl());
        }
        if (!ObjectUtils.isEmpty(ppt.getSubmitTime())) {
            queryWrapper = queryWrapper.like("submit_time", ppt.getSubmitTime());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptMaker())) {
            queryWrapper = queryWrapper.like("ppt_maker", ppt.getPptMaker());
        }
        if (!ObjectUtils.isEmpty(ppt.getStatusCode())) {
            queryWrapper = queryWrapper.like("status_code", ppt.getStatusCode());
        }
        if (!ObjectUtils.isEmpty(ppt.getIsDelete())) {
            queryWrapper = queryWrapper.like("is_delete", ppt.getIsDelete());
        }
        queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);
        SysUser sysUser = pptService.getUserByUserName(Utility.getCurrentUsername());
        //获取登录人分配的所有稿件id
        List<Long> groupByUserId = pptService.getAllotDraftIdByUserId(sysUser.getId());
        if (groupByUserId.size()!=0){
            log.info("========音视频校对组长分配出去的稿件Allot========"+groupByUserId);
            //判断分配的稿件id与PPT的稿件相同
            queryWrapper.in("draft_id", groupByUserId);
            log.info("===========音视频校对组长分配出去的ppt=========="+pptService.list(queryWrapper));
            //判断PPTstatuscode是板块负责人通过的
            queryWrapper.in("tp.status_code",
                    StatusPPTAudio.STATUS_PPT_FUNCTIONARY_SUCCESS,//1034
                    StatusPPTAudio.STATUS_PPT_BUTTJOJINT_DISTRIBUTION,//1031
                    StatusPPTAudio.STATUS_PPT_FUNCTIONARY_DISTRIBUTION,//1030
                    StatusPPTAudio.STATUFUNCTIONARY_FAILED,//2029
                    StatusPPTAudio.STATUFUNCTIONARY_SUCCESS_L,//1029
                    StatusPPTAudio.STATUFUNCTIONARY_FAILED_F,//2028
                    StatusPPTAudio.STATUFUNCTIONARY_SUCCESS,//1028
                    StatusPPTAudio.STATUFUNCTIONARY_SUCCESS_O,//1027
                    StatusPPTAudio.STATUS_FUNCTIONARY_SUCCESS_L,//1039
                    StatusPPTAudio.STATUS_FUNCTIONARY_FAILED,//2038
                    StatusPPTAudio.STATUS_FUNCTIONARY_SUCCESS,//1038
                    StatusPPTAudio.STATUS_T_FUNCTIONARY_FAILED//1037
            );

            IPage<Ppt> pageInfo = pptService.listPage(page, queryWrapper);
//            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
//
//            //稿件标题+文件名
//            Map<Long,String> map=new HashMap<>();
//            Map<Long,String> filemap=new HashMap<>();
//            List<Ppt> list = pptService.list(queryWrapper);
//            for (int i = 0; i < list.size(); i++) {
//                map.put(list.get(i).getId(),draftService.getTitleById(list.get(i).getDraftId()));
//                filemap.put(list.get(i).getId(),draftService.getFileNameById(list.get(i).getDraftId()));
//            }
//            model.addAttribute("map",map);
//            model.addAttribute("filemap",filemap);

            return prefix + "AuViLeaderSuccessReviewed";
        }else{
            queryWrapper.lambda().eq(Ppt::getStatusCode, StatusWriter.ERROR);
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "AuViLeaderSuccessReviewed";
        }

    }

    /**
     * @author 孙祺至
     * @date 2019年12月16日11:26:34
     * 音视频校对组长
     * 校对拒绝PPT
     */
    @RequestMapping("auviLeaderFailed")
    public String auviLeaderFailed(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
        if (!ObjectUtils.isEmpty(ppt.getDraftId())) {
            queryWrapper = queryWrapper.like("draft_id", ppt.getDraftId());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptUrl())) {
            queryWrapper = queryWrapper.like("ppt_url", ppt.getPptUrl());
        }
        if (!ObjectUtils.isEmpty(ppt.getSubmitTime())) {
            queryWrapper = queryWrapper.like("submit_time", ppt.getSubmitTime());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptMaker())) {
            queryWrapper = queryWrapper.like("ppt_maker", ppt.getPptMaker());
        }
        if (!ObjectUtils.isEmpty(ppt.getStatusCode())) {
            queryWrapper = queryWrapper.like("status_code", ppt.getStatusCode());
        }
        if (!ObjectUtils.isEmpty(ppt.getIsDelete())) {
            queryWrapper = queryWrapper.like("is_delete", ppt.getIsDelete());
        }
        queryWrapper.lambda().orderByDesc(Ppt::getCreateTime);
        SysUser sysUser = pptService.getUserByUserName(Utility.getCurrentUsername());
        //获取登录人分配的所有稿件id
        List<Long> groupByUserId = pptService.getAllotDraftIdByUserId(sysUser.getId());
        if (groupByUserId.size()!=0) {
            //判断分配的稿件id与PPT的稿件相同
            queryWrapper.in("draft_id", groupByUserId);
            //判断PPTstatuscode是板块负责人通过的
            queryWrapper.eq("tp.status_code", StatusPPTAudio.STATUS_PPT_FUNCTIONARY_FAILED);
//            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            IPage<Ppt> pageInfo = pptService.listPage(page, queryWrapper);
//            //稿件标题+文件名
//            Map<Long,String> map=new HashMap<>();
//            Map<Long,String> filemap=new HashMap<>();
//            List<Ppt> list = pptService.list(queryWrapper);
//            for (int i = 0; i < list.size(); i++) {
//                map.put(list.get(i).getId(),draftService.getTitleById(list.get(i).getDraftId()));
//                filemap.put(list.get(i).getId(),draftService.getFileNameById(list.get(i).getDraftId()));
//            }
//            model.addAttribute("map",map);
//            model.addAttribute("filemap",filemap);

            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "AuViLeaderFailedReviewed";
        }else{
            queryWrapper.lambda().eq(Ppt::getStatusCode, StatusWriter.ERROR);
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "AuViLeaderFailedReviewed";
        }
    }

    /**
     * 添加跳转页面
     * @return
     */
    @GetMapping("addBefore")
    public String addBefore() {
        return prefix + "add";
    }

     @GetMapping("lookBefore/{id}")
    public String lookBefore(@PathVariable("id") Long id, Model model) {
        log.info("===========lookBefore=============>{}", id);
        model.addAttribute("id", id);
        return prefix + "lookManuscript";
    }
    /**
     * 添加
     *
     * @param ppt
     * @return
     */
    @PostMapping("add")
    @ResponseBody
    public AjaxResult add(Ppt ppt) {
        return toAjax(pptService.save(ppt));
    }

    /**
     * 添加跳转页面
     *
     * @return
     */
    @GetMapping("editBefore/{id}")
    public String editBefore(Model model, @PathVariable("id") Long id) {
        model.addAttribute("ppt", pptService.getById(id));
        return prefix + "edit";
    }

    /**
     * 添加
     *
     * @param ppt
     * @return
     */
    @PostMapping("edit")
    @ResponseBody
    public AjaxResult edit(Ppt ppt) {
        return toAjax(pptService.updateById(ppt));
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @GetMapping("delete/{id}")
    @ResponseBody
    public AjaxResult delete(@PathVariable("id") Long id) {
        return toAjax(pptService.removeById(id));
    }

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @PostMapping("deleteAll")
    @ResponseBody
    public AjaxResult deleteAll(@RequestBody List<Long> ids) {
        return toAjax(pptService.removeByIds(ids));
    }


    /**
     * @Author 张雪
     * @Description 音视频校对组长--待分配PPT
     * @Date 2019/12/19 17:43
     * @Param
     * @return
     **/
    @RequestMapping("unAllot")
    public String unAllot(Model model,@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,@RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {

        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
        if (!ObjectUtils.isEmpty(ppt.getDraftId())) {
            queryWrapper = queryWrapper.like("draft_id", ppt.getDraftId());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptUrl())) {
            queryWrapper = queryWrapper.like("ppt_url", ppt.getPptUrl());
        }
        if (!ObjectUtils.isEmpty(ppt.getSubmitTime())) {
            queryWrapper = queryWrapper.like("submit_time", ppt.getSubmitTime());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptMaker())) {
            queryWrapper = queryWrapper.like("ppt_maker", ppt.getPptMaker());
        }
        if (!ObjectUtils.isEmpty(ppt.getStatusCode())) {
            queryWrapper = queryWrapper.like("submit_status", ppt.getStatusCode());
        }
        if (!ObjectUtils.isEmpty(ppt.getIsDelete())) {
            queryWrapper = queryWrapper.like("is_delete", ppt.getIsDelete());
        }
        queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);
        queryWrapper.lambda().eq(Ppt::getStatusCode, StatusPPTAudio.STATUS_PPT_AUVELEADER_SUCCESS);//1016
        IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
        model.addAttribute("submitTimeSpace", submitTimeSpace);
        model.addAttribute("searchInfo", ppt);
        model.addAttribute("pageInfo", new PageInfo(pageInfo));
        return prefix + "leader/unAllot";
    }
    /**
     * @Author 张雪
     * @Description 点击跳转到leader/allot.html
     * @Date 2019/12/9 11:08
     **/
    @GetMapping("allotBefore")
    public String allotBefore(Model model,String ids) {
        String username = Utility.getCurrentUsername();
        List<SysUser> workers = pptService.selectAllWorker(username);
        List<SysUser> newWorkers=new ArrayList<>();
        for (SysUser worker : workers) {
            List<SysRole> roles = worker.getRoles();
            for (SysRole role : roles) {
                if (com.mbyte.easy.common.constant.SysRole.VIDEO_PROOFREADER.equals(role.getId())){
                    newWorkers.add(worker);
                }
            }
        }
        List<String> usernameList = newWorkers.stream().map(SysUser::getUsername).collect(Collectors.toList());
        log.info("PPT待分配--所有下属 -->{}", usernameList);
        model.addAttribute("usernameList", usernameList);
        model.addAttribute("idsBus",ids);
        return prefix + "leader/allot";
    }

    /**
     * @Author 张雪 刘辉
     * @Description 点击跳转到worker/allot.html
     * @Date 2019/12/9 11:08
     **/
    @GetMapping("allotBeforeWorker")
    public String allotBeforeWorker(Model model,String ids,String statusCode,String groupId) {

        Long status=Long.valueOf(statusCode);
        if (status==1034){
        String username = Utility.getCurrentUsername();
        List<SysUser> workers = pptService.selectAllWorker(username);
        List<String> usernameList = workers.stream().map(SysUser::getUsername).collect(Collectors.toList());
        log.info("PPT待分配--所有下属 -->{}", usernameList);
        model.addAttribute("usernameList", usernameList);
        model.addAttribute("idsBus",ids);
        model.addAttribute("statusCode",statusCode);
        model.addAttribute("groupId",groupId);
        return prefix + "worker/allot1";
        }else {
        SysUser sysUser = audioService.getUserIdByUserName(Utility.getCurrentUsername());
        List<Long> childrenId = audioService.getChildrenIdByParentId(sysUser.getId());
        Map<Long,String> map = new HashMap<>();
        for (int i = 0; i < childrenId.size(); i++) {
            SysUser children = userService.selectByPrimaryKey(childrenId.get(i));
            List<com.mbyte.easy.security.entity.SysRole> childrenRoles = children.getRoles();
            for (com.mbyte.easy.security.entity.SysRole childrenRole : childrenRoles) {

                if (com.mbyte.easy.common.constant.SysRole.PPT_Checker.equals(childrenRole.getId()))
                {
                    map.put(childrenId.get(i),draftService.getUserNameByUserId(childrenId.get(i)).getUsername());
                }
            }
        }

        model.addAttribute("usernameList",map);
        model.addAttribute("idsBus",ids);
        model.addAttribute("statusCode",statusCode);
        model.addAttribute("groupId",groupId);
        return prefix + "worker/allot";
        }
    }

    /**
     * @return
     * @Author 张雪
     * @Description 按状态筛选PPT表 已分配
     * @Date 2019/12/9 10:14
     * @Param
     **/

    @RequestMapping("overIndex")
    public String overIndex(Model model, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        return prefix+"alloted";
    }
    @RequestMapping("alloted")
    public String alloted(Model model,@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,@RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {

        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
        if (!ObjectUtils.isEmpty(ppt.getDraftId())) {
            queryWrapper = queryWrapper.like("draft_id", ppt.getDraftId());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptUrl())) {
            queryWrapper = queryWrapper.like("ppt_url", ppt.getPptUrl());
        }
        if (!ObjectUtils.isEmpty(ppt.getSubmitTime())) {
            queryWrapper = queryWrapper.like("submit_time", ppt.getSubmitTime());
        }
        if (!ObjectUtils.isEmpty(ppt.getPptMaker())) {
            queryWrapper = queryWrapper.like("ppt_maker", ppt.getPptMaker());
        }
        if (!ObjectUtils.isEmpty(ppt.getStatusCode())) {
            queryWrapper = queryWrapper.like("submit_status", ppt.getStatusCode());
        }
        if (!ObjectUtils.isEmpty(ppt.getIsDelete())) {
            queryWrapper = queryWrapper.like("is_delete", ppt.getIsDelete());
        }
        queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);
        SysUser userIdByUserName = draftService.getUserIdByUserName(Utility.getCurrentUsername());
        List<Allot> draftByUserId = draftService.getDraftByUserId(userIdByUserName.getId());

        QueryWrapper<Allot> allot = new QueryWrapper<>();
        allot.lambda().eq(Allot::getAllotId,userIdByUserName.getId())
                .eq(Allot::getStatusCode, StatusRecordVideo.STATUS_PPT_AUDIO_AUVELEADER_SEND);
        List<Allot> list = allotService.list(allot);
        Map<Long,String> map = new HashMap<>();
        for(int i=0;i<list.size();i++){
            SysUser userNameByUserId = draftService.getUserNameByUserId(list.get(i).getAllotnoId());
            map.put(list.get(i).getDraftId(),userNameByUserId.getUsername());
        }
        model.addAttribute("map",map);




        if (draftByUserId.size()!=0){
//            queryWrapper.in("id",draftByUserId.stream().map(Allot::getDraftId).collect(Collectors.toList()));
           queryWrapper.lambda().eq(Ppt::getStatusCode, StatusRecordVideo.STATUS_PPT_AUDIO_AUVELEADER_SEND);//1017
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "leader/alloted";
        }else {
            queryWrapper.lambda().eq(Ppt::getStatusCode,"-1");
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "leader/alloted";
        }
    }
    /**
     * @Author 刘辉 孙祺至
     * @Description 录屏课程对接人--待分配到录屏制作人
     * @Date 2019/12/9 10:14
     * @Param
     * @return
     **/
    @RequestMapping("unAllotToMaker")
    public String unAllotToMaker(Model model,
                                 String draftTitle,
                                 @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,@RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();
        if (!ObjectUtils.isEmpty(submitTimeSpace)){
        queryWrapper.between("tp.submit_time", DateUtil.getStart(submitTimeSpace)
                    ,DateUtil.getEnd(submitTimeSpace).plusDays(1));
        }

        //搜索分组
        if(!ObjectUtils.isEmpty(ppt.getGroupId())) {
            QueryWrapper<Group> groupQueryWrapper=new QueryWrapper<>();
            groupQueryWrapper.lambda().like(Group::getName,ppt.getGroupId());
            List<Group> list = groupService.list(groupQueryWrapper);
            if (list.size()!=0){
                queryWrapper = queryWrapper.in("tp.group_id",list.stream().map(Group::getGroupId).collect(Collectors.toList()));
            }else {
                queryWrapper.eq("tp.group_id", -1);
            }
        }
         //搜索稿件标题
        if (!ObjectUtils.isEmpty(draftTitle)) {
            QueryWrapper<Draft> queryWrappers = new QueryWrapper<Draft>();
            queryWrappers.like("draft_title", draftTitle);
            List<Draft> draftsList = draftService.list(queryWrappers);
            List<Long> draftId0 = new ArrayList<>();
            if (draftsList.size()!=0){
                 for (int i = 0; i < draftsList.size(); i++) {
                draftId0.add(draftsList.get(i).getId());
            }
                 queryWrapper.in("draft_id", draftId0);
            }else{
                queryWrapper.in("draft_id", -1);
            }
        }

        List<Allot> draftByUserId = draftService.
        getDraftByAllotnoId(draftService.getUserIdByUserName(Utility.getCurrentUsername()).getId());
        if (draftByUserId.size()!=0){
            queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);
            queryWrapper.in("draft_id",draftByUserId.stream().map(Allot::getDraftId).collect(Collectors.toList()));
            queryWrapper.eq("tp.status_code",StatusPPTAudio.STATUS_PPT_FUNCTIONARY_SUCCESS);//1034
            IPage<Ppt> pageInfo = pptService.listPage(page,queryWrapper);

            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("draftTitle",draftTitle);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix+"worker/unAllot";
        }else {
            queryWrapper.lambda().eq(Ppt::getStatusCode,"-1");
            queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix+"worker/unAllot";
        }
    }
    /**
     * @Author 刘辉
     * @Description 录屏课程对接人---已分配到制作人
     * @Date 2019/12/9 10:14
     * @Param
     * @return
     **/
    @RequestMapping("allotedToMaker")
    public String allotedToMaker(Model model,@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,@RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();

        if(!ObjectUtils.isEmpty(ppt.getGroupId())) {
            QueryWrapper<Group> groupQueryWrapper=new QueryWrapper<>();
            groupQueryWrapper.lambda().like(Group::getName,ppt.getGroupId());
            List<Group> list = groupService.list(groupQueryWrapper);
            if (list.size()!=0){
                queryWrapper = queryWrapper.in("tp.group_id",list.stream().map(Group::getGroupId).collect(Collectors.toList()));
            }else {
                queryWrapper.eq("tp.group_id", -1);
            }
        }

        queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);
        SysUser userIdByUserName = draftService.getUserIdByUserName(Utility.getCurrentUsername());
        List<Allot> draftByUserId = allotMapper.getAllotBycodes(userIdByUserName.getId(),StatusRecordVideo.STATUS_RECORD_BUTTJOJINT_DISTRIBUTION);


        if (draftByUserId.size()!=0){
            queryWrapper.eq("tp.status_code", StatusRecordVideo.STATUS_RECORD_BUTTJOJINT_DISTRIBUTION);//1036
            queryWrapper.in("td.id",draftByUserId.stream().map(Allot::getDraftId).collect(Collectors.toList()));

            IPage<Ppt> pageInfo = pptMapper.listPagessss(page,queryWrapper);


            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix+"worker/alloted";
        }else{
            queryWrapper.lambda().eq(Ppt::getStatusCode,"-1");
            IPage<Ppt> pageInfo = pptService.page(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix+"worker/alloted";
        }
    }




    /**
     * @Author 刘辉
     * @Description 音视频校对组长--待分配到课程校对人的录屏
     * @Date 2020/02/04
     **/
    @RequestMapping("unAllotToChecker")
    public String unAllotToChecker(Model model,@RequestParam(value = "pageNo",
            required = false, defaultValue = "1") Integer pageNo,
       @RequestParam(value = "pageSize", required = false, defaultValue = "20")
               Integer pageSize, String submitTimeSpace,
                                   String createTimeSpace,
                                   String updateTimeSpace, Video video ) {
        Page<Video> page = new Page<Video>(pageNo, pageSize);
        QueryWrapper<Video> queryWrapper = new QueryWrapper<Video>();

          if (!ObjectUtils.isEmpty(submitTimeSpace)){
             queryWrapper.between("tv.submit_time", DateUtil.getStart(submitTimeSpace)
                    ,DateUtil.getEnd(submitTimeSpace).plusDays(1));
             }

            queryWrapper.lambda().orderByDesc(Video::getUpdateTime);
          queryWrapper.eq("tv.status_code",StatusRecordVideo.STATUS_RECORD_FUNCTIONARY_SUCCESS);

            IPage<Video> pageInfo = videoMapper.listPagess(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", video);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix+"pptVideo/unAllot";
    }



    /**
     * @Author 刘辉
     * @Description 音视频校对组长--已分配到课程校对人的录屏
     * @Date 2020/02/04
     **/
    @RequestMapping("allotedToChecker")
    public String allotedToChecker(Model model,@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,@RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace,
                                   String createTimeSpace, String updateTimeSpace,
                                   Video video) {
        Page<Video> page = new Page<Video>(pageNo, pageSize);
        QueryWrapper<Video> queryWrapper = new QueryWrapper<Video>();
        if (!ObjectUtils.isEmpty(submitTimeSpace)){
        queryWrapper.between("tv.submit_time", DateUtil.getStart(submitTimeSpace)
                    ,DateUtil.getEnd(submitTimeSpace).plusDays(1));
        }

        queryWrapper.lambda().orderByDesc(Video::getUpdateTime);
        SysUser userIdByUserName = draftService.getUserIdByUserName(Utility.getCurrentUsername());
        List<Allot> draftByUserId = draftService.getDraftByUserId(userIdByUserName.getId());

        if (draftByUserId.size()!=0){
            queryWrapper.eq("tv.status_code", StatusRecordVideo.STATUS_RECORD_AUVELEADER_DISTRIBUTION);//1037
//            queryWrapper.in("tv.draft_id",draftByUserId.stream().map(Allot::getDraftId).collect(Collectors.toList()));
            queryWrapper.eq("tv.draft_type", StatusRecordVideo.STATUS_VIDEO_RECORD_AUVEFINALLEADER_DRAFT_TYPE2);

            IPage<Video> pageInfo = videoMapper.listPagess(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", video);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix+"pptVideo/alloted";
        }else{
            queryWrapper.eq("tv.status_code","-1");
            IPage<Video> pageInfo = videoMapper.listPagess(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("searchInfo", video);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix+"pptVideo/alloted";
        }
    }




    /**
     * @param ids
     * @return
     * @author 孙祺至
     * @date 2019年12月16日16:47:28
     * 板块负责人
     * 批量通过
     * false为通过
     */
    @PostMapping("successAll")
    @ResponseBody
    public AjaxResult successAll(@RequestBody List<Long> ids) {
        log.info("========================>{}", ids);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<>();
        Ppt ppt = new Ppt();
        ppt.setStatusCode(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_SUCCESS);
        ppt.setUpdateTime(LocalDateTime.now());
        ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
        queryWrapper.in("id", ids);
        pptService.update(ppt, queryWrapper);

        for (int i = 0; i < ids.size(); i++) {
            Check check = new Check();
            check.setIsPass(true);
            check.setCreateTime(LocalDateTime.now());
            check.setUpdateTime(LocalDateTime.now());
            check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOAD);
            check.setOverStatusCode(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_SUCCESS);
            check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
            //check表draft插入PPT表的id
            check.setDraftId(pptService.getOne(new QueryWrapper<Ppt>().eq("id", ids.get(i))).getId());
            pptService.insertCheck(check);
        }
        return toAjax(true);
    }

    /**
     * @param
     * @return
     * @author 孙祺至
     * @date 2019年12月16日16:47:28
     * 板块负责人
     * 获取 拒绝 id
     */
    @GetMapping("failedBefore/{id}")
    public String failedAll(@PathVariable("id") Long id, Model model) {
        log.info("===========failedBefore=============>{}", id);
        model.addAttribute("id", id);
        return prefix + "SectionLeaderFailedReason";
    }

    /**
     * @param
     * @return
     * @author 孙祺至
     * @date 2019年12月16日16:47:28
     *
     * 拒绝
     */
    @PostMapping("SectionLeaderFailedReason")
    @ResponseBody
    public AjaxResult SectionLeaderFailedReason(Long draftId, String reason,String draftTitle,String draftText,Long draftNum,String fileName) {
        Long rolesId = sysUserRolesMapper.selectByUserId(pptService.selectIdByUsername(Utility.getCurrentUsername())).get(0).getRolesId();//获取登陆者角色id
        log.info("=======SectionLeaderFailedReason==========>{}", draftId);
        log.info("========================>{}", reason);
        if (rolesId== com.mbyte.easy.common.constant.SysRole.Block_Leader) {
            Ppt bydraftId = pptService.getBydraftId(draftId);
            Ppt ppt = new Ppt();
            ppt.setId(bydraftId.getId());
            ppt.setStatusCode(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_FAILED);
            ppt.setUpdateTime(LocalDateTime.now());
            ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
            pptService.updateById(ppt);


            Check check = new Check();
            check.setIsPass(false);
            check.setCreateTime(LocalDateTime.now());
            check.setUpdateTime(LocalDateTime.now());
            check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOAD);
            check.setOverStatusCode(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_FAILED);
            check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
            check.setDraftId(pptService.getOne(new QueryWrapper<Ppt>().eq("id", bydraftId.getId())).getId());
            check.setReason(reason);
            checkService.save(check);
        }
        //对接人
        if (rolesId== com.mbyte.easy.common.constant.SysRole.PPT_BROKER) {
            Draft byId = draftService.getById(draftId);
            byId.setDraftTitle(draftTitle);
            byId.setDraftText(draftText);
            byId.setFileName(fileName);
            byId.setDraftNum(draftNum);
            if (draftService.updateById(byId)){
                applicationEventPublisher.publishEvent(new DraftLog()
                        .setGroupId(draftService.getById(draftId).getGroupId())
                        .setActionType(DraftLogConstant.ACTION_EDIT)
                        .setActionContent("稿件更新成功")
                        .setCreateTime(LocalDateTime.now())
                        .setUserId(Utility.getSysUser().getId())
                        .setReason(reason)
                        .setDraftId(draftId));
//                        .setPrimaryState(StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOADTO)
//                        .setAfterState(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_FAILED)););
            };

            Ppt bydraftId = pptService.getBydraftId(draftId);
            Ppt ppt = new Ppt();
            ppt.setId(bydraftId.getId());
            ppt.setStatusCode(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_FAILED);
            ppt.setUpdateTime(LocalDateTime.now());
            ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
            pptService.updateById(ppt);


            Check check = new Check();
            check.setIsPass(false);
            check.setCreateTime(LocalDateTime.now());
            check.setUpdateTime(LocalDateTime.now());
            check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOADTO);
            check.setOverStatusCode(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_FAILED);
            check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
            check.setDraftId(pptService.getOne(new QueryWrapper<Ppt>().eq("id", bydraftId.getId())).getId());
            check.setReason(reason);
            checkService.save(check);

            //操作日志
            applicationEventPublisher.publishEvent(new DraftLog()
                    .setGroupId(draftService.getById(draftId).getGroupId())
                    .setActionType(DraftLogConstant.ACTION_CHECK_NO)
                    .setCreateTime(LocalDateTime.now())
                    .setUserId(Utility.getSysUser().getId())
                    .setReason(reason)
                    .setDraftId(draftId)
                    .setPrimaryState(StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOADTO)
                    .setAfterState(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_FAILED));

        }
        //负责人
        if (rolesId== com.mbyte.easy.common.constant.SysRole.PPT_RESPONSEBLE) {
            Draft byId = draftService.getById(draftId);
            byId.setDraftTitle(draftTitle);
            byId.setDraftText(draftText);
            byId.setDraftNum(draftNum);
            byId.setFileName(fileName);
            if (draftService.updateById(byId)){
                applicationEventPublisher.publishEvent(new DraftLog()
                        .setGroupId(draftService.getById(draftId).getGroupId())
                        .setActionType(DraftLogConstant.ACTION_EDIT)
                        .setActionContent("稿件更新成功")
                        .setCreateTime(LocalDateTime.now())
                        .setUserId(Utility.getSysUser().getId())
                        .setReason(reason)
                        .setDraftId(draftId));
//                        .setPrimaryState(StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOADTO)
//                        .setAfterState(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_FAILED)););
            };
            Ppt bydraftId = pptService.getBydraftId(draftId);
            Ppt ppt = new Ppt();
            ppt.setId(bydraftId.getId());
            ppt.setStatusCode(StatusPPTAudio.STATUS_PPT_FUNCTIONARY_FAILED);
            ppt.setUpdateTime(LocalDateTime.now());
            ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
            pptService.updateById(ppt);


            Check check = new Check();
            check.setIsPass(false);
            check.setCreateTime(LocalDateTime.now());
            check.setUpdateTime(LocalDateTime.now());
            check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_SUCCESS);
            check.setOverStatusCode(StatusPPTAudio.STATUS_PPT_FUNCTIONARY_FAILED);
            check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
            check.setDraftId(pptService.getOne(new QueryWrapper<Ppt>().eq("id", bydraftId.getId())).getId());
            check.setReason(reason);
            checkService.save(check);

            //操作日志
            applicationEventPublisher.publishEvent(new DraftLog()
                    .setGroupId(draftService.getById(draftId).getGroupId())
                    .setActionType(DraftLogConstant.ACTION_CHECK_NO)
                    .setCreateTime(LocalDateTime.now())
                    .setUserId(Utility.getSysUser().getId())
                    .setDraftId(draftId)
                    .setReason(reason)
                    .setPrimaryState(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_SUCCESS)
                    .setAfterState(StatusPPTAudio.STATUS_PPT_FUNCTIONARY_FAILED));
        }
        if (rolesId== com.mbyte.easy.common.constant.SysRole.Audio_Video_Checker){
            Ppt ppt = new Ppt();
            ppt.setId(pptService.getBydraftId(draftId).getId());
            ppt.setStatusCode(StatusPPTAudio.STATUS_PPT_VIDEOREADER_FAILED);
            ppt.setUpdateTime(LocalDateTime.now());
            ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
            pptService.updateById(ppt);


            Check check = new Check();
            check.setIsPass(false);
            check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_SUCCESS);
            check.setOverStatusCode(StatusPPTAudio.STATUS_PPT_VIDEOREADER_FAILED);
            check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
            check.setDraftId(pptService.getBydraftId(draftId).getId());
            check.setReason(reason);
            check.setCreateTime(LocalDateTime.now());
            check.setUpdateTime(LocalDateTime.now());
            pptService.insertCheck(check);
        }
        if (rolesId== com.mbyte.easy.common.constant.SysRole.AUDIO_VIDEO_CHECK_LEADER) {

            Ppt ppt = new Ppt();
            ppt.setId(pptService.getBydraftId(draftId).getId());
            ppt.setStatusCode(STATUS_PPT_AUVELEADER_FAILED);
            ppt.setUpdateTime(LocalDateTime.now());
            ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
            pptService.updateById(ppt);


            Check check = new Check();
            check.setIsPass(false);
            check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_VIDEOREADER_SUCCESS);
            check.setOverStatusCode(STATUS_PPT_AUVELEADER_FAILED);
            check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
            check.setDraftId(pptService.getBydraftId(draftId).getId());
            check.setReason(reason);
            check.setCreateTime(LocalDateTime.now());
            check.setUpdateTime(LocalDateTime.now());
            pptService.insertCheck(check);
        }
        return AjaxResult.success();
    }
    @PostMapping("change")
    @ResponseBody
    public AjaxResult change(Long draftId,String draftTitle,String draftText,Long draftNum,String fileName) {
        Draft byId = draftService.getById(draftId);
        byId.setDraftTitle(draftTitle);
        byId.setDraftText(draftText);
        byId.setFileName(fileName);
        byId.setDraftNum(draftNum);
        draftService.updateById(byId);

        applicationEventPublisher.publishEvent(new DraftLog()
                .setGroupId(draftService.getById(draftId).getGroupId())
                .setActionType(DraftLogConstant.ACTION_EDIT)
                .setCreateTime(LocalDateTime.now())
                .setActionContent("稿件更新成功")
                .setUserId(Utility.getSysUser().getId())
                .setDraftId(draftId)
                .setPrimaryState(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_SUCCESS)
//                .setAfterState(StatusPPTAudio.STATUS_PPT_FUNCTIONARY_SUCCESS)
        );
        return AjaxResult.success();
    }

    /**
     * @param
     * @return
     * @author 孙祺至
     * @date 2019年12月16日16:47:28
     * 板块负责人查看驳回理由
     * PPT
     */
    @GetMapping("failedReasonBefore/{id}")
    public String failedReasonBefore(@PathVariable("id") Long id, Model model) {
        List<Check> checkById = pptService.getCheckById(id);
        log.info("checkById==================>>{}",checkById);
        log.info("当前登录人：==============>>{}",pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
        log.info("true Or false???>>>>>>{}",pptService.getUserByUserName(Utility.getCurrentUsername()).getId()==checkById.get(0).getUserId());
        for (int i = 0; i < checkById.size(); i++) {
            if (pptService.getUserByUserName(Utility.getCurrentUsername()).getId()==checkById.get(i).getUserId()
                    &&checkById.get(i).getIsPass()==false
                    &&checkById.get(i).getOverStatusCode().equals(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_FAILED)
            ){
                model.addAttribute("check", checkById.get(i).getReason());
                log.info("check================={}",checkById.get(i).getReason());
                return prefix + "FailedReasonBefore";
            }
        }
        return prefix + "FailedReasonBefore";
    }
    @GetMapping("VfailedReasonBefore/{id}")
    public String VfailedReasonBefore(@PathVariable("id") Long id, Model model) {
        List<Check> checkById = pptService.getCheckById(id);
        log.info("checkById==================>>{}",checkById);
        log.info("当前登录人：==============>>{}",pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
        log.info("true Or false???>>>>>>{}",pptService.getUserByUserName(Utility.getCurrentUsername()).getId()==checkById.get(0).getUserId());
        for (int i = 0; i < checkById.size(); i++) {
            if (pptService.getUserByUserName(Utility.getCurrentUsername()).getId()==checkById.get(i).getUserId()
                    &&checkById.get(i).getIsPass()==false
                    &&checkById.get(i).getOverStatusCode().equals(StatusPPTAudio.STATUS_PPT_VIDEOREADER_FAILED)
            ){
                model.addAttribute("check", checkById.get(i).getReason());
                log.info("check================={}",checkById.get(i).getReason());
                return prefix + "FailedReasonBefore";
            }
        }
        return prefix + "FailedReasonBefore";
    }
    @GetMapping("AVfailedReasonBefore/{id}")
    public String AVfailedReasonBefore(@PathVariable("id") Long id, Model model) {
        List<Check> checkById = pptService.getCheckById(id);
        log.info("checkById==================>>{}",checkById);
        log.info("当前登录人：==============>>{}",pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
        for (int i = 0; i < checkById.size(); i++) {
            if (pptService.getUserByUserName(Utility.getCurrentUsername()).getId()==checkById.get(i).getUserId()
                    &&checkById.get(i).getIsPass()==false
                    &&checkById.get(i).getOverStatusCode().equals(STATUS_PPT_AUVELEADER_FAILED)
            ){
                model.addAttribute("check", checkById.get(i).getReason());
                log.info("check================={}",checkById.get(i).getReason());
                return prefix + "FailedReasonBefore";
            }
        }
        return prefix + "FailedReasonBefore";
    }
    /**
     * @param
     * @return
     * @author 孙祺至
     * @date 2019年12月16日16:47:28
     * 板块负责人查看被驳回理由
     * PPT
     */
    @GetMapping("BefailedReasonBefore/{id}")
    public String BefailedReasonBefore(@PathVariable("id") Long id, Model model) {
        List<Check> checkById = pptService.getCheckById(id);
        log.info("====id=========="+id);

        if (pptService.selectGroupIdById(id).getStatusCode().equals(StatusPPTAudio.STATUS_PPT_VIDEOREADER_FAILED)){
            if (checkById.size()!=0){
                for (int i = 0; i < checkById.size(); i++) {
                    if (pptService.getById(id).getLastOperator().equals(checkById.get(i).getUserId())&&checkById.get(i).getIsPass()==false
                            &&checkById.get(i).getOverStatusCode().equals(StatusPPTAudio.STATUS_PPT_VIDEOREADER_FAILED)){
                        model.addAttribute("check", checkById.get(i).getReason());
                        return prefix + "FailedReasonBefore";
                    }
                }
            }
        }
        if (pptService.selectGroupIdById(id).getStatusCode().equals(STATUS_PPT_AUVELEADER_FAILED)){
            if (checkById.size()!=0){
                for (int i = 0; i < checkById.size(); i++) {
                    if (pptService.getById(id).getLastOperator().equals(checkById.get(i).getUserId())&&checkById.get(i).getIsPass()==false
                            &&checkById.get(i).getOverStatusCode().equals(STATUS_PPT_AUVELEADER_FAILED)){
                        model.addAttribute("check", checkById.get(i).getReason());
                        return prefix + "FailedReasonBefore";
                    }
                }
            }
        }
//        for (int i = 0; i < checkById.size(); i++) {
//            if ((checkById.get(i).getIsPass()==true
//                    &&checkById.get(i).getPreStatusCode().equals(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_SUCCESS)
//                    &&checkById.get(i).getOverStatusCode().equals(StatusPPTAudio.STATUS_PPT_VIDEOREADER_FAILED))
//            ||(checkById.get(i).getIsPass()==true
//                    &&checkById.get(i).getPreStatusCode().equals(StatusPPTAudio.STATUS_PPT_VIDEOREADER_SUCCESS)
//                    &&checkById.get(i).getOverStatusCode().equals(STATUS_PPT_AUVELEADER_FAILED))){
//                model.addAttribute("check", checkById.get(i).getReason());
//                return prefix + "FailedReasonBefore";
//            }
//        }
        return prefix + "FailedReasonBefore";
    }
      /**
     * @param
     * @return
     * @author 孙祺至
     * @date 2019年12月16日16:47:28
     * 视频校对人查看被驳回理由
     * PPT
     */
    @GetMapping("aBefailedReasonBefore/{id}")
    public String aBefailedReasonBefore(@PathVariable("id") Long id, Model model) {
        List<Check> checkById = pptService.getCheckById(id);
        log.info("===========传进来的id是=======>>>>{}",id);
        log.info("==========根据id查找的check表数据=======>>>>{}",checkById);
        for (int i = 0; i < checkById.size(); i++) {
            if (pptService.getById(id).getLastOperator().equals(checkById.get(i).getUserId())
                    &&checkById.get(i).getIsPass()
                    &&checkById.get(i).getPreStatusCode().equals(StatusPPTAudio.STATUS_PPT_VIDEOREADER_SUCCESS)
                    &&checkById.get(i).getOverStatusCode().equals(STATUS_PPT_AUVELEADER_FAILED)){
                model.addAttribute("check", checkById.get(i).getReason());
                return prefix + "FailedReasonBefore";
            }
        }
        return prefix + "FailedReasonBefore";
    }

    /**
     * @param
     * @return
     * @author 孙祺至
     * @date 2019年12月16日16:47:28
     * PPT录屏制作人查看驳回理由
     */
    @GetMapping("PPTfailedReasonBefore/{id}")
    public String PPTfailedReasonBefore(@PathVariable("id") Long id, Model model) {
        List<Check> checkById = pptService.getCheckById(id);
        log.info("checkById==================>>{}",checkById);
       log.info("===================判断条件========="+pptService.getById(id).getLastOperator());
if (pptService.selectGroupIdById(id).getStatusCode().equals(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_FAILED)){
    if (checkById.size()!=0){
        for (int i = 0; i < checkById.size(); i++) {
            if (pptService.getById(id).getLastOperator().equals(checkById.get(i).getUserId())&&checkById.get(i).getIsPass()==false
                    &&checkById.get(i).getOverStatusCode().equals(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_FAILED)){
                model.addAttribute("check", checkById.get(i).getReason());
                return prefix + "FailedReasonBefore";
            }
        }
    }
}
        if (pptService.selectGroupIdById(id).getStatusCode().equals(StatusPPTAudio.STATUS_PPT_VIDEOREADER_FAILED)){
            if (checkById.size()!=0){
                for (int i = 0; i < checkById.size(); i++) {
                    if (pptService.getById(id).getLastOperator().equals(checkById.get(i).getUserId())&&checkById.get(i).getIsPass()==false
                            &&checkById.get(i).getOverStatusCode().equals(StatusPPTAudio.STATUS_PPT_VIDEOREADER_FAILED)){
                        model.addAttribute("check", checkById.get(i).getReason());
                        return prefix + "FailedReasonBefore";
                    }
                }
            }
        }
        if (pptService.selectGroupIdById(id).getStatusCode().equals(STATUS_PPT_AUVELEADER_FAILED)){
            if (checkById.size()!=0){
                for (int i = 0; i < checkById.size(); i++) {
                    if (pptService.getById(id).getLastOperator().equals(checkById.get(i).getUserId())&&checkById.get(i).getIsPass()==false
                            &&checkById.get(i).getOverStatusCode().equals(STATUS_PPT_AUVELEADER_FAILED)){
                        model.addAttribute("check", checkById.get(i).getReason());
                        return prefix + "FailedReasonBefore";
                    }
                }
            }
        }
        return prefix + "FailedReasonBefore";
    }

    /**
     * @param ids
     * @return
     * @author 孙祺至
     * @date 2019年12月16日16:47:28
     * 视频校对人
     * 批量通过
     */
    @PostMapping("VReadersuccessAll")
    @ResponseBody
    public AjaxResult VReadersuccessAll(@RequestBody List<Long> ids) {
        log.info("========================>{}", ids);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<>();
        Ppt ppt = new Ppt();
        ppt.setStatusCode(StatusPPTAudio.STATUS_PPT_VIDEOREADER_SUCCESS);
        ppt.setUpdateTime(LocalDateTime.now());
        ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
        queryWrapper.in("id", ids);
        pptService.update(ppt, queryWrapper);

        for (int i = 0; i < ids.size(); i++) {
            Check check = new Check();
            check.setIsPass(true);
            check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_SUCCESS);
            check.setOverStatusCode(StatusPPTAudio.STATUS_PPT_VIDEOREADER_SUCCESS);
            check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
            check.setCreateTime(LocalDateTime.now());
            check.setUpdateTime(LocalDateTime.now());
            check.setDraftId(pptService.getOne(new QueryWrapper<Ppt>().eq("id", ids.get(i))).getId());
            pptService.insertCheck(check);
        }
        return toAjax(true);
    }
    /**
     * @param
     * @return
     * @author 孙祺至
     * @date 2019年12月16日16:47:28
     * 视频校对人
     * 获取 拒绝 id
     */
    @GetMapping("VReaderfailedBefore/{id}")
    public String VReaderfailedBefore(@PathVariable("id") Long id, Model model) {
        log.info("===========failedBefore=============>{}", id);
        model.addAttribute("id", id);
        return prefix + "VReaderFailedReason";
    }
    /**
     * @param id,reason
     * @return
     * @author 孙祺至
     * @date 2019年12月16日16:47:28
     * 视频校对人
     * 拒绝
     */
    @PostMapping("VReaderFailedReason")
    @ResponseBody
    public AjaxResult VReaderFailedReason(Long id, String reason) {
        log.info("=======SectionLeaderFailedReason==========>{}", id);
        log.info("========================>{}", reason);
        Ppt ppt = new Ppt();
        ppt.setId(id);
        ppt.setStatusCode(StatusPPTAudio.STATUS_PPT_VIDEOREADER_FAILED);
        ppt.setUpdateTime(LocalDateTime.now());
        ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
        pptService.updateById(ppt);


        Check check = new Check();
        check.setIsPass(false);
        check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_SUCCESS);
        check.setOverStatusCode(StatusPPTAudio.STATUS_PPT_VIDEOREADER_FAILED);
        check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
        check.setDraftId(pptService.getOne(new QueryWrapper<Ppt>().eq("id", id)).getId());
        check.setReason(reason);
        check.setCreateTime(LocalDateTime.now());
        check.setUpdateTime(LocalDateTime.now());
        pptService.insertCheck(check);
        return AjaxResult.success();
    }
    /**
     * @author 孙祺至
     * @date 2019年12月16日16:47:28
     * 音视频校对组长
     * 批量通过
     */
    @PostMapping("AuViLeadersuccessAll")
    @ResponseBody
    public AjaxResult AuViLeadersuccessAll(@RequestBody List<Long> ids) {
        log.info("========================>{}", ids);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<>();
        Ppt ppt = new Ppt();
        ppt.setStatusCode(StatusPPTAudio.STATUS_PPT_FUNCTIONARY_SUCCESS);//1034
        ppt.setUpdateTime(LocalDateTime.now());
        ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
        queryWrapper.in("id", ids);
        pptService.update(ppt, queryWrapper);

        for (int i = 0; i < ids.size(); i++) {
            Check check = new Check();
            check.setIsPass(true);
            check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_SUCCESS);
            check.setOverStatusCode(StatusPPTAudio.STATUS_PPT_FUNCTIONARY_SUCCESS);
            check.setCreateTime(LocalDateTime.now());
            check.setUpdateTime(LocalDateTime.now());
            check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
            check.setDraftId(pptService.getOne(new QueryWrapper<Ppt>().eq("id", ids.get(i))).getId());
            pptService.insertCheck(check);
        }

        //操作日志
        for (int i = 0; i < ids.size(); i++) {
            applicationEventPublisher.publishEvent(new DraftLog()
                    .setGroupId(pptService.getById(ids.get(i)).getGroupId())
                    .setActionType(DraftLogConstant.ACTION_CHECK_NO)
                    .setCreateTime(LocalDateTime.now())
                    .setUserId(Utility.getSysUser().getId())
                    .setDraftId(pptService.getById(ids.get(i)).getDraftId())
                    .setPrimaryState(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_SUCCESS)
                    .setAfterState(StatusPPTAudio.STATUS_PPT_FUNCTIONARY_SUCCESS));
        }


        return toAjax(true);
    }
    /**
     * @author 孙祺至
     * @date 2019年12月16日16:47:28
     * 音视频校对组长
     * 获取 拒绝 id
     */
    @GetMapping("AuViLeaderfailedBefore/{id}")
    public String AuViLeaderfailedBefore(@PathVariable("id") Long id, Model model) {
        log.info("===========failedBefore=============>{}", id);
        model.addAttribute("id", id);
        return prefix + "AuViLeaderFailedReason";
    }
    /**
     * @author 孙祺至
     * @date 2019年12月16日16:47:28
     * 音视频校对组长
     * 拒绝
     */
    @PostMapping("AuViLeaderFailedReason")
    @ResponseBody
    public AjaxResult AuViLeaderFailedReason(Long id, String reason) {
        log.info("=======SectionLeaderFailedReason==========>{}", id);
        log.info("========================>{}", reason);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<>();
        Ppt ppt = new Ppt();
        ppt.setStatusCode(STATUS_PPT_AUVELEADER_FAILED);
        ppt.setUpdateTime(LocalDateTime.now());
        ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
        queryWrapper.in("id", id);
        pptService.update(ppt, queryWrapper);


        Check check = new Check();
        check.setIsPass(false);
        check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_VIDEOREADER_SUCCESS);
        check.setOverStatusCode(STATUS_PPT_AUVELEADER_FAILED);
        check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
        check.setDraftId(pptService.getOne(new QueryWrapper<Ppt>().eq("id", id)).getId());
        check.setReason(reason);
        check.setCreateTime(LocalDateTime.now());
        check.setUpdateTime(LocalDateTime.now());
        pptService.insertCheck(check);
        return toAjax(true);
    }


//    录屏制作===========================
    /**
     * @Author 张雪 刘辉
     * @Description PPT录屏制作人--待制作
     * @Date 2019/12/18 14:37
     * @Param
     * @return
     **/
    @RequestMapping("unMakePptVideo")
    public String unMakePptVideo(Model model,
                                 String draftTitle,
                                 @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,@RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, String submitTimeSpace, String createTimeSpace, String updateTimeSpace, Ppt ppt) {
        Page<Ppt> page = new Page<Ppt>(pageNo, pageSize);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<Ppt>();

        //搜索稿件标题
        Draft draft=new Draft();
          Map<List<Long>,String> drafttitles=new HashMap<>();
        if (!ObjectUtils.isEmpty(draftTitle)) {
            QueryWrapper<Draft> queryWrappers = new QueryWrapper<Draft>();
            queryWrappers.like("draft_title", draftTitle);
            List<Draft> draftsList = draftService.list(queryWrappers);
            if (draftsList.size()!=0){
                queryWrapper.in("tp.draft_id",draftsList.stream().map(Draft::getId).collect(Collectors.toList()));
            }else{
                queryWrapper.in("tp.draft_id", -1);
            }
        }

       Long currentUserId = pptService.selectIdByUsername(Utility.getCurrentUsername());
        //分配表中id为自己的稿件id
        QueryWrapper<Allot> queryWrapper1 = new QueryWrapper<>();
        queryWrapper1.eq("status_code", StatusRecordVideo.STATUS_RECORD_BUTTJOJINT_DISTRIBUTION);
        queryWrapper1.eq("allotNo_id", currentUserId);
        List<Allot> allotList = allotService.list(queryWrapper1);

        List<Long> draftIds = new ArrayList<>();
        if (allotList.size()!=0) {
            for (int i = 0; i < allotList.size(); i++) {
                draftIds.add(allotList.get(i).getDraftId());
            }
            queryWrapper.in("ta.draft_id", draftIds);
            queryWrapper.eq("ta.status_code", StatusRecordVideo.STATUS_RECORD_BUTTJOJINT_DISTRIBUTION);
            queryWrapper.lambda().orderByDesc(Ppt::getUpdateTime);

            IPage<Ppt> pageInfo = pptMapper.listPagessss(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
             model.addAttribute("draftTitle",draftTitle);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "maker/unMakePptVideo";
        }else {
             log.info("==================分配给它的PPTid============");
            queryWrapper.eq("tp.status_code", StatusWriter.ERROR);//-1
            IPage<Ppt> pageInfo = pptMapper.listPagessss(page, queryWrapper);
            model.addAttribute("submitTimeSpace", submitTimeSpace);
            model.addAttribute("draftTitle",draftTitle);
            model.addAttribute("searchInfo", ppt);
            model.addAttribute("pageInfo", new PageInfo(pageInfo));
            return prefix + "maker/unMakePptVideo";
        }
    }

    /**
     * oss 文件下载
     * @param pptId ppt主键
     */
    @PostMapping(value = "ossDownloadFile",produces="application/json")
    public void downloadFile(@RequestParam("pptId") String pptId, HttpServletResponse response) {
        log.info("pptId===================== "+pptId);

         String  path = pptService.getById(Long.valueOf(pptId)).getPptUrl();
        log.info("path===================== "+path);
        log.info("开始文件下载===================== ");
        OssUtil.download2FileByStream(path,response);
    }
    /**
     * @Author 孙祺至
     * @date 2019年12月23日17:53:04
     * 板块负责人
     * 单个通过
     * @return
     */
    @PostMapping("successById")
    @ResponseBody
    public AjaxResult successById(Long id,Long draftId,String draftText,String draftTitle,Long draftNum,String fileName) {
        Long rolesId = sysUserRolesMapper.selectByUserId(pptService.selectIdByUsername(Utility.getCurrentUsername())).get(0).getRolesId();//获取登陆者角色id
        if (rolesId== com.mbyte.easy.common.constant.SysRole.Block_Leader) {
            Ppt bydraftId = pptService.getBydraftId(draftId);
            QueryWrapper<Ppt> queryWrapper = new QueryWrapper<>();
            Ppt ppt = new Ppt();
            ppt.setStatusCode(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_SUCCESS);
            ppt.setUpdateTime(LocalDateTime.now());
            ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
            queryWrapper.eq("id", bydraftId.getId());
            pptService.update(ppt, queryWrapper);


            Check check = new Check();
            check.setIsPass(true);
            check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOAD);
            check.setOverStatusCode(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_SUCCESS);
            check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
            //check表draft插入PPT表的id
            check.setDraftId(bydraftId.getId());
            check.setCreateTime(LocalDateTime.now());
            check.setUpdateTime(LocalDateTime.now());
            checkService.save(check);
        }
        //对接人
        if (rolesId== com.mbyte.easy.common.constant.SysRole.PPT_BROKER) {
            Draft byId = draftService.getById(draftId);
            byId.setDraftText(draftText);
            byId.setDraftTitle(draftTitle);
            byId.setFileName(fileName);
            byId.setDraftNum(draftNum);
            if (draftService.updateById(byId)){
                applicationEventPublisher.publishEvent(new DraftLog()
                        .setGroupId(draftService.getById(draftId).getGroupId())
                        .setActionType(DraftLogConstant.ACTION_EDIT)
                        .setActionContent("稿件更新成功")
                        .setCreateTime(LocalDateTime.now())
                        .setUserId(Utility.getSysUser().getId())
                        .setDraftId(draftId));
//                        .setPrimaryState(StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOADTO)
//                        .setAfterState(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_FAILED)););
            };

            Ppt bydraftId = pptService.getBydraftId(draftId);
            QueryWrapper<Ppt> queryWrapper = new QueryWrapper<>();
            Ppt ppt = new Ppt();
            ppt.setStatusCode(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_SUCCESS);
            ppt.setUpdateTime(LocalDateTime.now());
            ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
            queryWrapper.eq("id", bydraftId.getId());
            pptService.update(ppt, queryWrapper);


            Check check = new Check();
            check.setIsPass(true);
            check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOADTO);
            check.setOverStatusCode(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_SUCCESS);
            check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
            //check表draft插入PPT表的id
            check.setDraftId(bydraftId.getId());
            check.setCreateTime(LocalDateTime.now());
            check.setUpdateTime(LocalDateTime.now());
            checkService.save(check);

            //操作日志
            applicationEventPublisher.publishEvent(new DraftLog()
                    .setGroupId(draftService.getById(draftId).getGroupId())
                    .setActionType(DraftLogConstant.ACTION_CHECK_YES)
                    .setCreateTime(LocalDateTime.now())
                    .setUserId(Utility.getSysUser().getId())
                    .setDraftId(draftId)
                    .setPrimaryState(StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOADTO)
                    .setAfterState(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_SUCCESS));
        }
 //负责人
        if (rolesId== com.mbyte.easy.common.constant.SysRole.PPT_RESPONSEBLE) {
            Draft byId = draftService.getById(draftId);
            byId.setDraftText(draftText);
            byId.setDraftTitle(draftTitle);
            byId.setFileName(fileName);
            byId.setDraftNum(draftNum);
            if (draftService.updateById(byId)){
                applicationEventPublisher.publishEvent(new DraftLog()
                        .setGroupId(draftService.getById(draftId).getGroupId())
                        .setActionType(DraftLogConstant.ACTION_EDIT)
                        .setActionContent("稿件更新成功")
                        .setCreateTime(LocalDateTime.now())
                        .setUserId(Utility.getSysUser().getId())
                        .setDraftId(draftId));
//                        .setPrimaryState(StatusPPTAudio.STATUS_PPT_PPTTORECORD_UPLOADTO)
//                        .setAfterState(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_FAILED)););
            };

            Ppt bydraftId = pptService.getBydraftId(draftId);
            QueryWrapper<Ppt> queryWrapper = new QueryWrapper<>();
            Ppt ppt = new Ppt();
            ppt.setStatusCode(StatusPPTAudio.STATUS_PPT_FUNCTIONARY_SUCCESS);
            ppt.setUpdateTime(LocalDateTime.now());
            ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
            queryWrapper.eq("id", bydraftId.getId());
            pptService.update(ppt, queryWrapper);


            Check check = new Check();
            check.setIsPass(true);
            check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_SUCCESS);
            check.setOverStatusCode(StatusPPTAudio.STATUS_PPT_FUNCTIONARY_SUCCESS);
            check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
            //check表draft插入PPT表的id
            check.setDraftId(bydraftId.getId());
            check.setCreateTime(LocalDateTime.now());
            check.setUpdateTime(LocalDateTime.now());
            checkService.save(check);

            //操作日志
            applicationEventPublisher.publishEvent(new DraftLog()
                    .setGroupId(draftService.getById(draftId).getGroupId())
                    .setActionType(DraftLogConstant.ACTION_CHECK_YES)
                    .setCreateTime(LocalDateTime.now())
                    .setUserId(Utility.getSysUser().getId())
                    .setDraftId(draftId)
                    .setPrimaryState(StatusPPTAudio.STATUS_PPT_BUTTJOJINT_SUCCESS)
                    .setAfterState(StatusPPTAudio.STATUS_PPT_FUNCTIONARY_SUCCESS));
        }

        if (rolesId== com.mbyte.easy.common.constant.SysRole.Audio_Video_Checker){
            Ppt bydraftId = pptService.getBydraftId(draftId);
            QueryWrapper<Ppt> queryWrapper = new QueryWrapper<>();
            Ppt ppt = new Ppt();
            ppt.setStatusCode(StatusPPTAudio.STATUS_PPT_VIDEOREADER_SUCCESS);
            ppt.setUpdateTime(LocalDateTime.now());
            ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
            queryWrapper.eq("id", bydraftId.getId());
            pptService.update(ppt, queryWrapper);


            Check check = new Check();
            check.setIsPass(true);
            check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_SUCCESS);
            check.setOverStatusCode(StatusPPTAudio.STATUS_PPT_VIDEOREADER_SUCCESS);
            check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
            check.setDraftId(bydraftId.getId());
            check.setCreateTime(LocalDateTime.now());
            check.setUpdateTime(LocalDateTime.now());
            pptService.insertCheck(check);
        }
        if (rolesId== com.mbyte.easy.common.constant.SysRole.AUDIO_VIDEO_FINAL_REVIEWER) {
            Ppt bydraftId = pptService.getBydraftId(draftId);
        }
        return AjaxResult.success();
    }
    /**
     * @Author 孙祺至
     * @date 2019年12月23日17:53:04
     * 音频校对人
     * 单个通过
     * @param id
     * @return
     */
    @GetMapping("VReaderSuccessById/{id}")
    @ResponseBody
    public AjaxResult VReaderSuccessById(@PathVariable("id") Long id) {
        log.info("========================>{}", id);
        QueryWrapper<Ppt> queryWrapper = new QueryWrapper<>();
        Ppt ppt = new Ppt();
        ppt.setStatusCode(StatusPPTAudio.STATUS_PPT_VIDEOREADER_SUCCESS);
        ppt.setUpdateTime(LocalDateTime.now());
        ppt.setLastOperator(pptService.selectIdByUsername(Utility.getCurrentUsername()));
        queryWrapper.in("id", id);
        pptService.update(ppt, queryWrapper);


            Check check = new Check();
            check.setIsPass(true);
            check.setPreStatusCode(StatusPPTAudio.STATUS_PPT_SECTIONLEADER_SUCCESS);
            check.setOverStatusCode(StatusPPTAudio.STATUS_PPT_VIDEOREADER_SUCCESS);
            check.setUserId(pptService.getUserByUserName(Utility.getCurrentUsername()).getId());
            check.setDraftId(id);
        check.setCreateTime(LocalDateTime.now());
        check.setUpdateTime(LocalDateTime.now());
            pptService.insertCheck(check);
        Long aLong = pptService.selectIdByUsername(Utility.getCurrentUsername());


        return toAjax(true);
    }
}


